package manong.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

public class Course implements Cloneable, Serializable {

    private Integer id;
    private String courseName;
    private Integer courseTime;
    private Integer statu;
    private String mark;
    private static final long serialVersionUID = 1L;

    public Course(Integer id, String courseName, Integer courseTime, Integer statu, String mark) {
        this.id = id;
        this.courseName = courseName;
        this.courseTime = courseTime;
        this.statu = statu;
        this.mark = mark;
    }

  
    public Course() {
        super();
    }


    public Integer getId() {
        return id;
    }

   
    public Course withId(Integer id) {
        this.setId(id);
        return this;
    }

   
    public void setId(Integer id) {
        this.id = id;
    }

  
    public String getCourseName() {
        return courseName;
    }

   
    public Course withCourseName(String courseName) {
        this.setCourseName(courseName);
        return this;
    }

   
    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

  Integer getCourseTime() {
        return courseTime;
    }

 
    public Course withCourseTime(Integer courseTime) {
        this.setCourseTime(courseTime);
        return this;
    }

   
    public void setCourseTime(Integer courseTime) {
        this.courseTime = courseTime;
    }

 
    public Integer getStatu() {
        return statu;
    }

   
    public Course withStatu(Integer statu) {
        this.setStatu(statu);
        return this;
    }

    public void setStatu(Integer statu) {
        this.statu = statu;
    }

    public String getMark() {
        return mark;
    }

 
    public Course withMark(String mark) {
        this.setMark(mark);
        return this;
    }

    
    public void setMark(String mark) {
        this.mark = mark;
    }

   
    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Course other = (Course) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCourseName() == null ? other.getCourseName() == null : this.getCourseName().equals(other.getCourseName()))
            && (this.getCourseTime() == null ? other.getCourseTime() == null : this.getCourseTime().equals(other.getCourseTime()))
            && (this.getStatu() == null ? other.getStatu() == null : this.getStatu().equals(other.getStatu()))
            && (this.getMark() == null ? other.getMark() == null : this.getMark().equals(other.getMark()));
    }

   
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCourseName() == null) ? 0 : getCourseName().hashCode());
        result = prime * result + ((getCourseTime() == null) ? 0 : getCourseTime().hashCode());
        result = prime * result + ((getStatu() == null) ? 0 : getStatu().hashCode());
        result = prime * result + ((getMark() == null) ? 0 : getMark().hashCode());
        return result;
    }


    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", courseName=").append(courseName);
        sb.append(", courseTime=").append(courseTime);
        sb.append(", statu=").append(statu);
        sb.append(", mark=").append(mark);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public Course clone() throws CloneNotSupportedException {
        return (Course) super.clone();
    }


    public enum Column {
        id("id", "id", "INTEGER", false),
        courseName("course_name", "courseName", "VARCHAR", false),
        courseTime("course_time", "courseTime", "INTEGER", false),
        statu("statu", "statu", "INTEGER", false),
        mark("mark", "mark", "VARCHAR", false);


        private static final String BEGINNING_DELIMITER = "`";

 
        private static final String ENDING_DELIMITER = "`";

        private final String column;

  
        private final boolean isColumnNameDelimited;

        private final String javaProperty;

        private final String jdbcType;

  
        public String value() {
            return this.column;
        }

      
        public String getValue() {
            return this.column;
        }

    
        public String getJavaProperty() {
            return this.javaProperty;
        }

    
        public String getJdbcType() {
            return this.jdbcType;
        }

      
        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }

       
        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

    
        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

     
        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

     
        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }
    }
}